//
//  LRecordScene.m
//  TouchDemo
//
//  Created by 李明明 on 16/1/19.
//  Copyright © 2016年 李明明. All rights reserved.
//

#import "LRecordScene.h"
#import "LRecordCell.h"
#import <objc/runtime.h>
#import "LLocation.h"
#import "LMapScene.h"
@interface LRecordScene ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) LLocation *location;
@property (nonatomic, weak) IBOutlet UITableView *list;
@end

@implementation LRecordScene {
    NSMutableArray *listArr;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    listArr = [@[] mutableCopy];
    NSArray *keys = self.dic.allKeys;
    for (NSString *key in keys) {
        [listArr insertObject:self.dic[key] atIndex:listArr.count];
    }
//    self.location = [[LLocation alloc] init];
//    [self.location setLocation:^(NSString *str) {
//        NSLog(@"%@", str);
//    }];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    LRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:@"recordcell"];
    [cell loadInfo:listArr[indexPath.row]];
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dic.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 80;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    LMapScene *mapScene = [[LMapScene alloc] init];
    [self.navigationController pushViewController:mapScene animated:YES];
}
- (NSArray<id<UIPreviewActionItem>> *)previewActionItems {
    UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:@"test" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
        if (self.item) {
            self.item(@0);
        }
    }];
    UIPreviewAction *action2 = [UIPreviewAction actionWithTitle:@"tests" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
        if (self.item) {
            self.item(@1);
        }
    }];
    return @[action1, action2];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
